import { getAction, putAction, postAction } from '@/api/manage'
import { serviceApi } from '@/api/common.js'

/**
 * 公共API接口
 */
export const api = {
  list: (tenantId) => serviceApi.auth + `/tenants/${tenantId}/children`,
  delete: (id) => serviceApi.auth + `/tenants/${id}`
}

/**
 * 树形结构加载
 * @param params
 * @returns {AxiosPromise}
 */
export const queryTenantTreeList = (tenantId, params) => getAction(serviceApi.auth + `/tenants/${tenantId}/trees`, params);

/**
 * 添加
 * @param {*} params
 * @returns
 */
export const addTenant = params => postAction(serviceApi.auth + '/tenants', params);

/**
 * 编辑
 * @param {*} params
 * @returns
 */
export const editTenant = params => putAction(serviceApi.auth + '/tenants', params);

/**
 *
 * @param {*} params
 * @returns
 */
export const queryById = (id, params) => getAction(serviceApi.auth + `/tenants/${id}`, params);

/**
 * 租户-用户的信息
 * @param {*} params
 * @returns
 */
export const getTenantUserInfoResult = (tenantId, userId) => getAction(serviceApi.auth + `/tenants/${tenantId}/users/${userId}`);

/**
 * 通过级别，父编码查询区划列表
 * @param params
 * @returns {AxiosPromise}
 */
export const listAreaByLevel = params => getAction(serviceApi.auth + '/areas/list-level-parent', params);
